package com.atguigu.test.boot.bean;

import com.atguigu.test.config.MyBatisAutoConfig;
import org.springframework.boot.autoconfigure.AutoConfigurationImportSelector;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Arrays;

/**
 * @author zp
 * @version 1.0
 * @description: 自定义扫描类
 * @date 2023/2/8 20:12
 */
public class MyImportSelector implements DeferredImportSelector {
    /**
     * @description: 加载 spring.factories文件当中的信息 初始化的时候注入对象
     * DeferredImportSelector 滞后加载的接口
     * @author zp
     * @date: 2023/2/10 19:30
     * @param importingClassMetadata
     * @return String[]
     */
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return SpringFactoriesLoader.loadFactoryNames(MyBatisAutoConfig.class,MyImportSelector.class.getClassLoader()).toArray(new String[0]);
    }
}
